package com.line.myprojectservice.config;

import com.line.myprojectservice.Interceptor.JwtInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author ：Line
 * @date ： 2022/3/31 16:20
 * @description :拦截器配置
 */
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {

    @Resource
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册Jwt拦截器
        InterceptorRegistration registration = registry.addInterceptor(jwtInterceptor);
        //所有路径都被拦截
        registration.addPathPatterns("/**");
        //排除配置 ，因为加了父路由所以这样写
        registration.excludePathPatterns("/**/user/login/**",
                "/**/user/register/**",
                "/**/files/**/**");
    }


}